<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<strong><%@ taglib prefix="c"
                   uri="http://java.sun.com/jsp/jstl/core" %></strong>
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>艺术品</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="stylesheet" href="/xAdmin/css/font.css">
    <link rel="stylesheet" href="/xAdmin/css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="/xAdmin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/xAdmin/js/xadmin.js"></script>

    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="">拍卖会管理</a>
            <a href="">艺术品</a>
          </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5">
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" class="layui-input"  autocomplete="off" placeholder="作品编号" name="artcode" id="artcode">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="name" id="name" placeholder="作品名称" autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
                        </div>
                    </form>
                </div>
                <script type="text/html" id="toolbarDemo">
                    <div class="layui-btn-container">
                        <button class="layui-btn layui-btn-sm" lay-event="getCheckData">添加</button>
                    </div>
                </script>
                <script type="text/html" id="barDemo">
                    <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
                    <a class="layui-btn layui-btn-xs" lay-event="del">删除</a>
                </script>
                <div class="layui-card-body ">
                    <input type="hidden" value="${result.pageNum}" id="pageNum">
                    <input type="hidden" value="${result.pageSize}" id="pageSize">
                    <input type="hidden" value="${result.totalSize}" id="totalSize">
                    <input type="hidden" value="${result.totalPages}" id="totalPages">
                    <input type="hidden" value="${auctionid}" id="auctionid">
                    <table class="layui-table layui-form" lay-filter="demo" id="demo">
                        <thead>
                        <tr>

                            <th lay-data="{type: 'checkbox'}"></th>
                            <th lay-data="{field:'artcode', width:80}">作品编号</th>
                            <th lay-data="{field:'name', width:80}">名称</th>
                            <th lay-data="{field:'mainpic', width:80}">图片</th>
                            <th lay-data="{field:'marketprice', width:80}">价格</th>
                            <th lay-data="{field:'number', width:80}">数量</th>
                            <th lay-data="{field:'salenum', width:80}">已售数量</th>
                            <th lay-data="{field:'salestate', width:80}">状态</th>
                            <th lay-data="{fixed: 'right', toolbar: '#barDemo', width:150}">操作</th>
                        </thead>
                        <tbody id="tBizArtList">
                        <c:forEach items="${result.content}" var="art" varStatus="status">
                            <tr>
                                <td>
                                    <input type="checkbox" lay-skin="primary">
                                </td>
                                <td>${art.artcode}</td>
                                <td>${art.name}</td>
                                <td><img src="${art.mainpic}"></td>
                                <td>${art.marketprice}</td>
                                <td>${art.number}</td>
                                <td>${art.salenum}</td>
                                <td>${art.salestate}</td>
                                <td ></td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body ">
                    <div class="page" id="page">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>

    layui.use('table', function(){
        var table = layui.table;
        table.init('demo', {
            height: 315 //设置高度
            ,limit: 10 //注意：请务必确保 limit 参数（默认：10）是与你服务端限定的数据条数一致
            //支持所有基础参数
            ,toolbar:'#toolbarDemo'
            ,defaultToolbar: []
            // ,done:function(res,curr,count){
            //
            // }
        });
        //头工具栏事件
        table.on('toolbar(demo)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id);
            switch(obj.event){
                case 'getCheckData':
                    var data = checkStatus.data;
                    layui.use('layer', function(){
                        var layer = parent.layui.layer;
                        var index = layer.open({
                            title: "添加拍卖作品",
                            type: 2,
                            area: ["900px","700px"],
                            content: '/tBizAuction/artlist?pageNum=1&pageSize=10&auctionid='+$('#auctionid').val(),
                            end: function () {
                                // console.log("回调2成功");
                                // refreshTable();
                            }
                        });
                    });
                    break;
                //自定义头工具栏右侧图标 - 提示
                case 'LAYTABLE_TIPS':
                    layer.alert('这是工具栏右侧自定义的一个图标按钮');
                    break;
            };
        });

        //监听行工具事件
        table.on('tool(demo)', function(obj){
            var data = obj.data;
            if(obj.event === 'edit'){
                // console.log(data.artcode);
                layui.use('layer', function(){
                    var layer = parent.layui.layer;
                    var index = layer.open({
                        title: "添加作品",
                        type: 2,
                        area: ["800px","600px"],
                        content: '/tBizAuction/auctionArtEdit?auctionId='+$('#auctionid').val()+"&artcode="+data.artcode,
                        end: function () {
                            // console.log("回调成功");
                            refreshTable();
                        }
                    });
                });
            }else if(obj.event == 'del'){
                $.ajax({
                    url:'/tBizAuction/auctionArtDel?auctionId='+$('#auctionid').val()+"&artcode="+data.artcode,
                    type:'GET',
                    dataType:'text',
                    contentType: 'application/json',
                    timeout:2000,
                    success:function(data){
                        var datas =JSON.parse( data );
                        var layer = parent.layui.layer;
                        if(datas.oper_res == 'success')
                            layer.msg('操作成功!',{icon:1,time:1000});
                        else
                            layer.msg('操作失败!',{icon:1,time:1000});
                        refreshTable();
                    },
                    error:function () {
                        var layer = parent.layui.layer;
                        layer.msg("操作失败",{icon:1,time:1000});
                    }
                });


            }

        });





    });

    layui.use(['laypage', 'layer'], function(){
        var laypage = layui.laypage
            ,layer = layui.layer;
        laypage.render({
            elem:'page'
            ,count:$('#totalSize').val()
            ,limit: $('#pageSize').val()
            ,groups: 5
            ,curr:$('#pageNum').val()
            ,first: 1
            ,last: $('#totalPages').val()
            ,jump: function(obj, first){
                //首次不执行
                if(!first){
                    window.location.href = "/tBizAuction/aalist?auctionid="+$('#auctionid').val()+"&pageNum="+obj.curr+"&pageSize="+obj.limit;
                }

            }
        });
    });

    function retrunDate() {
        console.log($('#tBizArtList >input:checkbox:checked').val());
    }
    function refreshTable(){
        window.location.reload();
    }

</script>
</html>
